package com.boco.transnms.common.dto.traph.statresource;

/**
 * <p>Title: TransNMS</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: Boco Inter-Telecom INC</p>
 *
 * @author not attributable
 * @version 1.0
 */
public class SubRowNumInfo  implements java.io.Serializable, Cloneable {
    private Integer freeNum=0;
    private Integer useNum=0;
    private Integer preUseNum=0;
    private Integer totalNum = 0;
    private Double percentNum = 0.0;

    public void calPercentNum(){
      if(totalNum!=0){
          percentNum = 100.0*freeNum / totalNum ;
          String strPercentNum = String.valueOf(percentNum);
          if(strPercentNum.length()>4){
            strPercentNum = strPercentNum.substring(0,4);
            percentNum = Double.valueOf(strPercentNum);
          }
      }
    }

    public void calTotalNum(){
      totalNum = freeNum + useNum + preUseNum;
    }

    public Integer getFreeNum() {
        return freeNum;
    }

    public void addFreeNum(){
      freeNum++;
    }

    public void addUseNum(){
      useNum++;
    }

    public void addPreUseNum(){
      preUseNum++;
    }

    public Double getPercentNum(){
      return this.percentNum;
    }

    public Integer getTotalNum(){
      return this.totalNum;
    }

    public Integer getUseNum() {
        return useNum;
    }

    public Integer getPreUseNum() {
        return preUseNum;
    }

    public void setFreeNum(Integer freeNum) {
        this.freeNum = freeNum;
    }

    public void setUseNum(Integer useNum) {
        this.useNum = useNum;
    }

    public void setPreUseNum(Integer preUseNum) {
        this.preUseNum = preUseNum;
    }

    public void addNumByRowNumInfo(SubRowNumInfo subRowNumInfo){
      this.freeNum = this.freeNum + subRowNumInfo.getFreeNum();
      this.useNum = this.useNum + subRowNumInfo.getUseNum();
      this.preUseNum = this.preUseNum + subRowNumInfo.getPreUseNum();
      this.totalNum = this.totalNum + subRowNumInfo.getTotalNum();
    }

}
